package com.gitee.feizns;

import java.util.stream.Stream;

/**
 * 流
 * @author feizns
 * @since 2019/6/9 0009
 */
public abstract class StreamUtils {

    /**
     * 留下第二个
     * @param t
     * @param t2
     * @param <T>
     * @return
     */
    public static final <T> T leaveSecond(T t, T t2) {
        return t2;
    }

    /**
     * 不做改变
     * @param original
     * @return
     */
    public static final <R> R noChangeFun(R original) {
        return original;
    }

    /**
     * 获取字节流
     * @param str
     * @return
     */
    public static final Stream<Character> stream(String str) {
        Stream.Builder<Character> builder = Stream.builder();
        if ( str != null ) {
            for (int i = 0; i < str.length(); i++) {
                builder.add(str.charAt(i));
            }
        }
        return builder.build();
    }

}
